﻿using Hidistro.Entities.Commodities;
using Hidistro.SaleSystem.Catalog;
using Hidistro.SaleSystem.Comments;
using Hidistro.UI.Common.Controls;
using System;
using System.Data;
using System.Data.OleDb;
using System.Web.UI.WebControls;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class yb_yqlj : AscxTemplatedWebControl
    {
        protected override void AttachChildControls()
        {
                string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + this.MapPathSecure("~/qingqu/data/#6Fy1Do.mdb") + ";";
                using (OleDbConnection cnn = new OleDbConnection(ConnectionString))
                {
                    string sql = string.Format("select top {0} t1.title,t1.id,t2.catedir from sd_content as t1 left join sd_category as t2 on t1.classid = t2.cateid  order by createdate desc", 24);
                    OleDbCommand cmd = new OleDbCommand(sql, cnn);
                    OleDbDataAdapter da = new OleDbDataAdapter();
                    da.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    ds.Tables[0].Columns.Add("name", typeof(System.String));

                    Repeater list = (Repeater)this.FindControl("list");
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr["title"].ToString().Length > 13)
                        {
                            dr["name"] = dr["title"].ToString().Substring(0, 13) + "...";
                        }
                        else
                        {
                            dr["name"] = dr["title"];
                        }
                    }
                    list.DataSource = ds.Tables[0];
                    list.DataBind();
                }

        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "/ascx/tags/Common_GoodsList/yb_yqlj.ascx";
            }
            base.OnInit(e);
        }
    }
}